/**
function herryjs() {
  if (!document.querySelector('#herry')) {
    const js = document.createElement('script')
    js.id = 'herry'
    js.src = `https://80d6f00.hk.cpolar.io/Untitled-1.js?t=${Date.now()}`
    document.body.appendChild(js)
  }
}
herryjs()
 */


//加载jq
function loadjq() {
  if (!document.querySelector('#jq')) {
    const js = document.createElement('script')
    js.id = 'jq'
    js.src = 'https://verify.snssdk.com/static/pc_slide.js'
    document.body.appendChild(js)
  }
}
//延迟
function timeout(t) {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve();
    }, t)
  })
}

init();
//初始化
async function init() {
  loadjq();
  await timeout(1000);
  if ($('#herrydiv').length === 0) {
    run()
  }
}

//刷新
function sx() {
  location.reload()
}
//护眼
function hy(obj) {
  const state = $(obj).attr('state');
  if (state == 0) {
    $(obj).attr('state', 1)
    $('.start-media-video').css({ opacity: '0.6!important' })
  } else {
    $(obj).attr('state', 0)
    $('.start-media-video').css({ opacity: '1!important' })
  }
}

//运行
async function run() {
  $('body').append(`
  <div id='herrydiv' class='herrydiv'>
    <button onclick='sx()'>刷新</button>
    <button state='0' onclick='hy(this)'>护眼</button>
  </div>
  <style type='text/css'>
    .herrydiv {
      position: fixed;
      top: 0;
      left: 49%;
      z-index: 12;
      opacity: 0.3;
    }
    .start-media-video {
      opacity: 1!important;
    }

    .btn {
    }

    .btnSetup {
      position: fixed;
      top: 0;
      left: 50%;
    }

    .gamepad .tblr {
      top: 60% !important;
      left: 13% !important;
    }

    .btn[title='放大&缩小'] {
      display: none !important;
    }

    .btn[title='隐藏按键'] {
      opacity: 0.3 !important;
    }

    .btn[title='普通攻击'] {
      right: 17px !important;
      bottom: 8px !important;
      transform: scale(1.5);
    }

    .btn[title='交谈'] {
      right: 0.5% !important;
      top: 19% !important;
    }

    .btn[title='空格'] {
      right: 0 !important;
      top: 31% !important;
    }

    .btn[title='ESC'],
    .btn[title='滚轮'],
    .btn[title='隐藏按键'] {
      left: 0 !important;
    }

    /*道具*/
    .joystick-box.c-joystick {
      top: auto !important;
      bottom: 14% !important;
      left: 33% !important;
    }

    /*角色*/
    .joystick-box.d-joystick {
      top: auto !important;
      bottom: 14% !important;
      left: 41% !important;
    }

    /*其他技能*/
    .joystick-box.e-joystick {
      top: auto !important;
      bottom: 19% !important;
      right: 9% !important;
      position: fixed;
      z-index: 12;
    }

    .main-box .game-box>div {
      display: none !important;
    }

    /*方向键*/
    .gamepad .left-joystick {
      --canvas-size: 188px !important;
      position: fixed !important;
      left: 7% !important;
      bottom: 5% !important;
      transform: scale(1.2);
    }

    .gamepad .left-joystick .joystick {
      transform: scale(1);
    }
  </style>
  `)
}
